import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  strict: true,
  state: {
    isLogin: false,
    videoUrl: '',
    allCategory: '1',
    user: {
      id: '',
      username: '',
      dsc: '',
      gender: '',
      age: ''
    }
  },
  getters: {
  },
  mutations: {
    changeIsLogin (state) {
      if (state.isLogin) {
        state.isLogin = false
      } else {
        state.isLogin = true
      }
    },
    saveAllCategory (state, newAllCategory) {
      state.allCategory = newAllCategory
    },
    saveVideoUrl (state, newVideoUrl) {
      state.videoUrl = newVideoUrl
    },
    saveId (state, newId) {
      state.user.id = newId
    },
    saveToken (state, token) {
      state.token = token
    },
    saveUsername (state, username) {
      state.user.username = username
    },
    savePassword (state, newPassword) {
      state.user.password = newPassword
    },
    saveDsc (state, newDsc) {
      state.user.dsc = newDsc
    },
    saveGender (state, newGender) {
      state.user.gender = newGender
    },
    saveAge (state, newAge) {
      state.user.age = newAge
    }
  },
  actions: {
  },
  modules: {
  }
})
